package com.douyang.controller;

import com.douyang.VO.GetLivePeople;
import com.douyang.VO.VideoUserInfoVO;
import com.douyang.base.expcetion.UserException;
import com.douyang.base.expcetion.VideoException;
import com.douyang.base.model.Result;
import com.douyang.service.UserVideoLikedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaoma
 * @since 2025-03-05
 */
@RestController
@RequestMapping("/user/userVideoLiked")
public class UserVideoLikedController {

    @Autowired
    private UserVideoLikedService userVideoLikedService;

    @GetMapping("/getVideoUserInfo")
    public Result<VideoUserInfoVO> getVideoUserInfo(Long authorId,Long videoId) {
        return Result.success(userVideoLikedService.getVideoUserInfo(authorId,videoId));
    }

    @PostMapping("/loveVideo")
    public Result<String> loveVideo(Long videoId) {
        userVideoLikedService.loveVideo(videoId);
        return Result.success("ok");
    }

    @DeleteMapping("/unLoveVideo")
    public Result<String> unLoveVideo(Long videoId) {
        userVideoLikedService.unLoveVideo(videoId);
        return Result.success("ok");
    }

    @GetMapping("/getVideoLikeCount/{videoId}")
    public Result<Integer> getVideoLikeCount(@PathVariable("videoId") Long videoId){
        return Result.success(userVideoLikedService.getVideoLikeCount(videoId));
    }

    @GetMapping("/getUserLikedVideoIds/{userId}")
    public Result<List<Long>> getUserLikedVideoIds(@PathVariable("userId") Long userId){
        return Result.success(userVideoLikedService.getUserLikedVideoIds(userId));
    }

    @PostMapping("/liveLike/{liveId}")
    public Result<String> liveLike(@PathVariable("liveId") Long liveId) {
        if(liveId == null)throw new UserException("id不能为null");
        userVideoLikedService.liveLike(liveId);
        return Result.success("ok");
    }

    @GetMapping("/getLivePeopleList")
    public Result<List<GetLivePeople>> getLivePeopleList(Long liveId){
        if(liveId == null)throw new UserException("id不能为null");
        return Result.success(userVideoLikedService.getLivePeopleList(liveId));
    }

}
